# 操作列表
# for in
# range
# list(range)
# 列表解析 [value**2 for value in range(1,10)]
# 列表切片
# 复制列表、复制切片
# 元组, 不可变列表 list = (10, 11)
magicians = ['alice', 'david', 'carolina']

for magician in magicians:
    print(magician.title() + ", tha was a great trick!")
    print("I can't wait to see your next trick, " + magician.title() + '.\n')

print('Thank you, everyone. That was a great magic show!')

print(magician)

# range 生成数字范围， list 转化列表
list_num = range(1, 5)
for value in list_num:
    print(value)

# print('list_num:', list_num)

numbes = list(range(1, 6))
print('numbes: ', numbes)

even_numbes = list(range(2, 11, 2))
print('even_numbes: ', even_numbes)

squares = []
for value in range(1, 11):
    squares.append(value ** 2)

print(squares)

# min max sum
digits = [1, 2, 3, 4, 5]

print('min', min(digits))
print('max', max(digits))
print('sum', sum(digits))

# 列表解析，这是什么语法？？？， for value in range(1, 11) 生成的 1-10，给 value**2 使用
squares = [value**2 for value in range(1, 11)]
print('squares', squares)

# 练习
for value in list(range(1, 21)):
    print('1-20', value)

count_list = list(range(1, 1000001))
print('count_list_min', min(count_list))
print('count_list_max', max(count_list))
print('count_list_sum', sum(count_list))

# 列表切片
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[0:-1])
print(players[0:])
print(players[:len(players)])
print(players[0:10])

# 遍历切片
for player in players[:3]:
    print(player.title())

# 复制切片, 修改复制后的列表不会影响原列表
my_foods = ['pizza', 'ffalafel', 'carrot cake']
friend_foods = my_foods[:]
# friend_foods = my_foods

# del friend_foods[0]

print('My foods', my_foods)

print('my friend foods', friend_foods)

# 元组， 不可变的列表称为元组
dimensions = (200, 50)
# 修改元组会报错
# dimensions[0] = 100

# 可以赋值
dimensions = (100, 10)
print(dimensions[0])
print(dimensions[1])